<?php

spl_autoload_register(function ($className) {
    $fileName = dirname(__FILE__).'/'.str_replace('\\', '/', $className).'.php';
    if (file_exists($fileName)) {
        require_once $fileName;
    }
});

$game = new \Tictactoe\Game($_POST['game']);

$move = new \Tictactoe\Ai\Move($game);

$bestMove = $move->getNextMoveForValue((int)$_POST['getNextMoveForValue']);


$res = array(
    'move' => $bestMove->getMove(),
    'estimate' => $bestMove->getEstimate(),
    'forValue' => $bestMove->getForValue(),
    'info' => $bestMove->getInfo()
);

echo json_encode($res);